<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>OPC UA 点位监控系统</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <link href="./style.css"  rel="stylesheet">
</head>
<body class="light-theme">
    <div class="container-fluid">
        <!-- 控制面板 -->
        <div class="card mb-4 shadow-sm">
            <div class="card-header bg-secondary text-white">
                <h5 class="mb-0"><i class="fas fa-cog me-2"></i>监控设置</h5>
            </div>
            <div class="card-body">
                <div class="d-flex justify-content-between align-items-center flex-wrap gap-3">
                    <div class="d-flex flex-wrap gap-3">
                        <div class="d-flex align-items-center">
                            <label for="intervalInput" class="form-label me-2 mb-0">扫描间隔（秒）:</label>
                            <input type="number" id="intervalInput" class="form-control" value="10" min="1" max="3600" style="width: 100px;">
                        </div>
                        <button id="updateIntervalBtn" class="btn btn-primary">
                            <i class="fas fa-sync me-1"></i>更新间隔
                        </button>
                        <button id="addPointBtn" class="btn btn-success">
                            <i class="fas fa-plus me-1"></i>新增点位
                        </button>
                        <button id="toggleMonitoringBtn" class="btn btn-warning">
                            <i class="fas fa-pause me-1"></i>暂停监控
                        </button>
                        <button id="refreshBtn" class="btn btn-info">
                            <i class="fas fa-sync me-1"></i>刷新
                        </button>
                    </div>
                    <div class="d-flex align-items-center">
                        <span class="me-2">运行状态:</span>
                        <span id="statusLabel" class="badge bg-success">运行中</span>
                        <div class="theme-switcher ms-3">
                            <button id="lightThemeBtn" class="btn btn-light btn-sm"><i class="fas fa-sun"></i> 明亮</button>
                            <button id="darkThemeBtn" class="btn btn-dark btn-sm ms-2"><i class="fas fa-moon"></i> 暗黑</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 点位表格 -->
        <div class="card shadow-sm">
            <div class="card-header bg-secondary text-white">
                <h5 class="mb-0"><i class="fas fa-table me-2"></i>OPC UA 点位</h5>
            </div>
            <div class="card-body p-0">
                <div class="table-container">
                    <table class="table table-striped table-hover mb-0">
                        <thead class="table-dark">
                            <tr>
                                <th>ID</th>
                                <th>名称</th>
                                <th>URL</th>
                                <th>Node ID</th>
                                <th>状态</th>
                                <th>最后检查</th>
                                <th>启用</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody id="pointsTableBody">
                            <!-- 数据将通过JavaScript动态加载 -->
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 新增/编辑点位模态框 -->
    <div class="modal fade" id="pointModal" tabindex="-1" aria-labelledby="pointModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="pointModalLabel">新增点位</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <form id="pointForm">
                        <input type="hidden" id="pointId">
                        <div class="mb-3">
                            <label for="pointName" class="form-label">名称</label>
                            <input type="text" class="form-control" id="pointName" required>
                        </div>
                        <div class="mb-3">
                            <label for="pointUrl" class="form-label">OPC UA URL</label>
                            <input type="text" class="form-control" id="pointUrl" placeholder="opc.tcp://host:port" required>
                        </div>
                        <div class="mb-3">
                            <label for="pointNodeId" class="form-label">Node ID</label>
                            <input type="text" class="form-control" id="pointNodeId" placeholder="ns=2;i=12345" required>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" id="savePointBtn">保存</button>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 删除确认模态框 -->
    <div class="modal fade" id="deleteModal" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="deleteModalLabel">确认删除</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <p>确定要删除这个点位吗？此操作不可恢复。</p>
                    <input type="hidden" id="deletePointId">
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-danger" id="confirmDeleteBtn">删除</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 消息通知区域 -->
    <div id="notification" class="notification" style="display: none;"></div>

    <!-- Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="./index.js"></script>
</body>
</html>